package com.hz.web.service.impl;


import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Service;

import com.hz.web.dao.VideoDao;
import com.hz.web.entity.UserEntity;
import com.hz.web.entity.Video;
import com.hz.web.service.IvideoService;

@SuppressWarnings("all")
@Service
public class VideoServiceImpl implements IvideoService {
	
	@Resource
	private VideoDao videoDao;

	@Override
	public List<Video> query(Map condition) {
		// TODO Auto-generated method stub
		return videoDao.query(condition);
	}

	@Override
	public int queryCount(Map condition) {
		// TODO Auto-generated method stub
		return videoDao.queryCount(condition);
	}

	@Override
	public List<Video> queryView(Map condition) {
		// TODO Auto-generated method stub
		return videoDao.queryView(condition);
	}



	@Override
	public int add(Video record,HttpSession session) {
		UserEntity user = new UserEntity();
		if(session.getAttribute("userinfo")!=null){
			user=(UserEntity) session.getAttribute("userinfo");
			record.setCreateUser(user.getId());
			record.setChangeUser(user.getId());;
		}
		return videoDao.add(record);
	}

	@Override
	public Video queryById(Video entity) {
		
		return videoDao.queryById(entity);
	}

	@Override
	public int update(Video record,HttpSession session) {
		UserEntity user = new UserEntity();
		if(session.getAttribute("userinfo")!=null){
			user=(UserEntity) session.getAttribute("userinfo");
			record.setCreateUser(user.getId());
			record.setChangeUser(user.getId());;
		}
		return videoDao.update(record);
	}

	@Override
	public int del(Video record) {
		// TODO Auto-generated method stub
		return videoDao.del(record);
	}
}
